package com.ruoyi.management.carservicestatics.service.impl;
import com.google.common.collect.Lists;

import java.util.*;
import java.util.stream.Collectors;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.management.basics.ro.GetVehiclesInformationListParam;
import com.ruoyi.management.basics.service.ITCarService;
import com.ruoyi.management.basics.vo.GetVehiclesInformationListVo;
import com.ruoyi.management.carservicestatics.ro.*;
import com.ruoyi.management.carservicestatics.vo.*;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.management.carservicestatics.mapper.TCarServiceStaticsMapper;
import com.ruoyi.management.carservicestatics.domain.TCarServiceStatics;
import com.ruoyi.management.carservicestatics.service.ITCarServiceStaticsService;
import org.springframework.transaction.annotation.Transactional;

/**
 * carservicestaticsService业务层处理
 * 
 * @author xly
 * @date 2021-12-08
 */
@Service
public class TCarServiceStaticsServiceImpl implements ITCarServiceStaticsService 
{
    @Autowired
    private TCarServiceStaticsMapper tCarServiceStaticsMapper;

    @Autowired
    private ITCarService tCarService;

    /**
     * 查询carservicestatics列表
     * 
     * @param tCarServiceStatics carservicestatics
     * @return carservicestatics
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<TCarServiceStatics> selectTCarServiceStaticsList(TCarServiceStatics tCarServiceStatics)
    {
        return tCarServiceStaticsMapper.selectTCarServiceStaticsList(tCarServiceStatics);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<GetCarServiceStaticsListVo> export(GetCarServiceStaticsListParam param) {
        List<GetCarServiceStaticsListVo> voList = tCarServiceStaticsMapper.export(param);
        for (GetCarServiceStaticsListVo vo : voList) {
            if (null != vo.getMonthDays() && !"".equals(vo.getMonthDays()) && null != vo.getMonthCounts() && !"".equals(vo.getMonthCounts())) {
                String[] days = vo.getMonthDays().split(",");
                String[] count = vo.getMonthCounts().split(",");
                for (String monthDay : days) {
                    for (String monthCounts : count) {
                        boolean dayBoolean1 = "01".equals(monthDay.substring(0, 2));
                        boolean dayBoolean2 = "02".equals(monthDay.substring(0, 2));
                        boolean dayBoolean3 = "03".equals(monthDay.substring(0, 2));
                        boolean dayBoolean4 = "04".equals(monthDay.substring(0, 2));
                        boolean dayBoolean5 = "05".equals(monthDay.substring(0, 2));
                        boolean dayBoolean6 = "06".equals(monthDay.substring(0, 2));
                        boolean dayBoolean7 = "07".equals(monthDay.substring(0, 2));
                        boolean dayBoolean8 = "08".equals(monthDay.substring(0, 2));
                        boolean dayBoolean9 = "09".equals(monthDay.substring(0, 2));
                        boolean dayBoolean10 = "10".equals(monthDay.substring(0, 2));
                        boolean dayBoolean11 = "11".equals(monthDay.substring(0, 2));
                        boolean dayBoolean12 = "12".equals(monthDay.substring(0, 2));
                        boolean countBoolean1 = "01".equals(monthCounts.substring(0, 2));
                        boolean countBoolean2 = "02".equals(monthCounts.substring(0, 2));
                        boolean countBoolean3 = "03".equals(monthCounts.substring(0, 2));
                        boolean countBoolean4 = "04".equals(monthCounts.substring(0, 2));
                        boolean countBoolean5 = "05".equals(monthCounts.substring(0, 2));
                        boolean countBoolean6 = "06".equals(monthCounts.substring(0, 2));
                        boolean countBoolean7 = "07".equals(monthCounts.substring(0, 2));
                        boolean countBoolean8 = "08".equals(monthCounts.substring(0, 2));
                        boolean countBoolean9 = "09".equals(monthCounts.substring(0, 2));
                        boolean countBoolean10 = "10".equals(monthCounts.substring(0, 2));
                        boolean countBoolean11 = "11".equals(monthCounts.substring(0, 2));
                        boolean countBoolean12 = "12".equals(monthCounts.substring(0, 2));
                        String dc = Integer.parseInt(monthDay.substring(3, monthDay.length())) + "/" + Integer.parseInt(monthCounts.substring(3, monthCounts.length()));
                        if (dayBoolean1 && countBoolean1) {
                            vo.setJanuary(dc);
                        } else if (dayBoolean2 && countBoolean2) {
                            vo.setFebruary(dc);
                        } else if (dayBoolean3 && countBoolean3) {
                            vo.setMarch(dc);
                        } else if (dayBoolean4 && countBoolean4) {
                            vo.setApril(dc);
                        } else if (dayBoolean5 && countBoolean5) {
                            vo.setMay(dc);
                        } else if (dayBoolean6 && countBoolean6) {
                            vo.setJune(dc);
                        } else if (dayBoolean7 && countBoolean7) {
                            vo.setJuly(dc);
                        } else if (dayBoolean8 && countBoolean8) {
                            vo.setAugust(dc);
                        } else if (dayBoolean9 && countBoolean9) {
                            vo.setSeptember(dc);
                        } else if (dayBoolean10 && countBoolean10) {
                            vo.setOctober(dc);
                        } else if (dayBoolean11 && countBoolean11) {
                            vo.setNovember(dc);
                        } else if (dayBoolean12 && countBoolean12) {
                            vo.setDecember(dc);
                        }
                    }
                }
            }
            String d = "0/0";
            if(StringUtils.isEmpty(vo.getJanuary())){
                vo.setJanuary(d);
            }
            if (StringUtils.isEmpty(vo.getFebruary())) {
                vo.setFebruary(d);
            }
            if (StringUtils.isEmpty(vo.getMarch())) {
                vo.setMarch(d);
            }
            if (StringUtils.isEmpty(vo.getApril())) {
                vo.setApril(d);
            }
            if (StringUtils.isEmpty(vo.getMay())) {
                vo.setMay(d);
            }
            if (StringUtils.isEmpty(vo.getJune())) {
                vo.setJune(d);
            }
            if (StringUtils.isEmpty(vo.getJuly())) {
                vo.setJuly(d);
            }
            if (StringUtils.isEmpty(vo.getAugust())) {
                vo.setAugust(d);
            }
            if (StringUtils.isEmpty(vo.getSeptember())) {
                vo.setSeptember(d);
            }
            if (StringUtils.isEmpty(vo.getOctober())) {
                vo.setOctober(d);
            }
            if (StringUtils.isEmpty(vo.getNovember())) {
                vo.setNovember(d);
            }
            if (StringUtils.isEmpty(vo.getDecember())) {
                vo.setDecember(d);
            }
        }
        return voList;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<GetCarServiceStaticsMonthListVo> selectStaticsList(GetCarServiceStaticsListParam param) {

        List<GetCarServiceStaticsMonthListVo> monthList = tCarServiceStaticsMapper.selectStaticsList(param);

        for (GetCarServiceStaticsMonthListVo vo : monthList)
        {
            if (null != vo && null != vo.getMonthDays() && !"".equals(vo.getMonthDays()))
            {
                String[] arr = vo.getMonthDays().split(",");
                for (String monthDay : arr)
                {
                    boolean dayBoolean1 = "01".equals(monthDay.substring(0, 2));
                    boolean dayBoolean2 = "02".equals(monthDay.substring(0, 2));
                    boolean dayBoolean3 = "03".equals(monthDay.substring(0, 2));
                    boolean dayBoolean4 = "04".equals(monthDay.substring(0, 2));
                    boolean dayBoolean5 = "05".equals(monthDay.substring(0, 2));
                    boolean dayBoolean6 = "06".equals(monthDay.substring(0, 2));
                    boolean dayBoolean7 = "07".equals(monthDay.substring(0, 2));
                    boolean dayBoolean8 = "08".equals(monthDay.substring(0, 2));
                    boolean dayBoolean9 = "09".equals(monthDay.substring(0, 2));
                    boolean dayBoolean10 = "10".equals(monthDay.substring(0, 2));
                    boolean dayBoolean11 = "11".equals(monthDay.substring(0, 2));
                    boolean dayBoolean12 = "12".equals(monthDay.substring(0, 2));
                    int day = Integer.parseInt(monthDay.substring(3, monthDay.length()));
                    if (dayBoolean1){
                        vo.setJanuaryDays(day);
                    } else if (dayBoolean2){
                        vo.setFebruaryDays(day);
                    } else if (dayBoolean3) {
                        vo.setMarchDays(day);
                    } else if (dayBoolean4) {
                        vo.setAprilDays(day);
                    }else if (dayBoolean5) {
                        vo.setMayDays(day);
                    }else if (dayBoolean6) {
                        vo.setJuneDays(day);
                    }else if (dayBoolean7) {
                        vo.setJulyDays(day);
                    }else if (dayBoolean8) {
                        vo.setAugustDays(day);
                    }else if (dayBoolean9) {
                        vo.setSeptemberDays(day);
                    }else if (dayBoolean10) {
                        vo.setOctoberDays(day);
                    }else if (dayBoolean11) {
                        vo.setNovemberDays(day);
                    }else if (dayBoolean12) {
                        vo.setDecemberDays(day);
                    }
                }
            }
            if (null != vo && null != vo.getMonthCounts() && !"".equals(vo.getMonthCounts()))
            {
                String[] arr = vo.getMonthCounts().split(",");
                for (String monthCounts : arr)
                {
                    boolean countBoolean1 = "01".equals(monthCounts.substring(0, 2));
                    boolean countBoolean2 = "02".equals(monthCounts.substring(0, 2));
                    boolean countBoolean3 = "03".equals(monthCounts.substring(0, 2));
                    boolean countBoolean4 = "04".equals(monthCounts.substring(0, 2));
                    boolean countBoolean5 = "05".equals(monthCounts.substring(0, 2));
                    boolean countBoolean6 = "06".equals(monthCounts.substring(0, 2));
                    boolean countBoolean7 = "07".equals(monthCounts.substring(0, 2));
                    boolean countBoolean8 = "08".equals(monthCounts.substring(0, 2));
                    boolean countBoolean9 = "09".equals(monthCounts.substring(0, 2));
                    boolean countBoolean10 = "10".equals(monthCounts.substring(0, 2));
                    boolean countBoolean11 = "11".equals(monthCounts.substring(0, 2));
                    boolean countBoolean12 = "12".equals(monthCounts.substring(0, 2));
                    int count = Integer.parseInt(monthCounts.substring(3, monthCounts.length()));
                    if (countBoolean1) {
                        vo.setJanuaryCounts(count);
                    } else if (countBoolean2) {
                        vo.setFebruaryCounts(count);
                    } else if (countBoolean3) {
                        vo.setMarchCounts(count);
                    } else if (countBoolean4) {
                        vo.setAprilCounts(count);
                    } else if (countBoolean5) {
                        vo.setMarchCounts(count);
                    } else if (countBoolean6) {
                        vo.setJuneCounts(count);
                    } else if (countBoolean7) {
                        vo.setJulyCounts(count);
                    } else if (countBoolean8) {
                        vo.setAugustCounts(count);
                    } else if (countBoolean9) {
                        vo.setSeptemberCounts(count);
                    } else if (countBoolean10) {
                        vo.setOctoberCounts(count);
                    } else if (countBoolean11) {
                        vo.setNovemberCounts(count);
                    } else if (countBoolean12) {
                        vo.setDecemberCounts(count);
                    }
                }
            }
        }

        return monthList;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<GetCarServiceStaticsDetailsVo> getEmployeeStaticsDetails(GetCarServiceStaticsDetailsParam param) {
        List<GetCarServiceStaticsDetailsVo> voList = tCarServiceStaticsMapper.selectStaticsDetailsList(param);
        for (GetCarServiceStaticsDetailsVo vo : voList)
        {
            if (null != vo && null != vo.getMonthDays() && !"".equals(vo.getMonthDays()))
            {
                String[] arr = vo.getMonthDays().split(",");
                for (String monthDay : arr)
                {
                    boolean dayBoolean1 = "01".equals(monthDay.substring(0, 2));
                    boolean dayBoolean2 = "02".equals(monthDay.substring(0, 2));
                    boolean dayBoolean3 = "03".equals(monthDay.substring(0, 2));
                    boolean dayBoolean4 = "04".equals(monthDay.substring(0, 2));
                    boolean dayBoolean5 = "05".equals(monthDay.substring(0, 2));
                    boolean dayBoolean6 = "06".equals(monthDay.substring(0, 2));
                    boolean dayBoolean7 = "07".equals(monthDay.substring(0, 2));
                    boolean dayBoolean8 = "08".equals(monthDay.substring(0, 2));
                    boolean dayBoolean9 = "09".equals(monthDay.substring(0, 2));
                    boolean dayBoolean10 = "10".equals(monthDay.substring(0, 2));
                    boolean dayBoolean11 = "11".equals(monthDay.substring(0, 2));
                    boolean dayBoolean12 = "12".equals(monthDay.substring(0, 2));
                    int day = Integer.parseInt(monthDay.substring(3, monthDay.length()));
                    if (dayBoolean1){
                        vo.setJanuaryDays(day);
                    } else if (dayBoolean2){
                        vo.setFebruaryDays(day);
                    } else if (dayBoolean3) {
                        vo.setMarchDays(day);
                    } else if (dayBoolean4) {
                        vo.setAprilDays(day);
                    }else if (dayBoolean5) {
                        vo.setMayDays(day);
                    }else if (dayBoolean6) {
                        vo.setJuneDays(day);
                    }else if (dayBoolean7) {
                        vo.setJulyDays(day);
                    }else if (dayBoolean8) {
                        vo.setAugustDays(day);
                    }else if (dayBoolean9) {
                        vo.setSeptemberDays(day);
                    }else if (dayBoolean10) {
                        vo.setOctoberDays(day);
                    }else if (dayBoolean11) {
                        vo.setNovemberDays(day);
                    }else if (dayBoolean12) {
                        vo.setDecemberDays(day);
                    }
                }
            }
            if (null != vo && null != vo.getMonthCounts() && !"".equals(vo.getMonthCounts()))
            {
                String[] arr = vo.getMonthCounts().split(",");
                for (String monthCounts : arr)
                {
                    boolean countBoolean1 = "01".equals(monthCounts.substring(0, 2));
                    boolean countBoolean2 = "02".equals(monthCounts.substring(0, 2));
                    boolean countBoolean3 = "03".equals(monthCounts.substring(0, 2));
                    boolean countBoolean4 = "04".equals(monthCounts.substring(0, 2));
                    boolean countBoolean5 = "05".equals(monthCounts.substring(0, 2));
                    boolean countBoolean6 = "06".equals(monthCounts.substring(0, 2));
                    boolean countBoolean7 = "07".equals(monthCounts.substring(0, 2));
                    boolean countBoolean8 = "08".equals(monthCounts.substring(0, 2));
                    boolean countBoolean9 = "09".equals(monthCounts.substring(0, 2));
                    boolean countBoolean10 = "10".equals(monthCounts.substring(0, 2));
                    boolean countBoolean11 = "11".equals(monthCounts.substring(0, 2));
                    boolean countBoolean12 = "12".equals(monthCounts.substring(0, 2));
                    int count = Integer.parseInt(monthCounts.substring(3, monthCounts.length()));
                    if (countBoolean1) {
                        vo.setJanuaryCounts(count);
                    } else if (countBoolean2) {
                        vo.setFebruaryCounts(count);
                    } else if (countBoolean3) {
                        vo.setMarchCounts(count);
                    } else if (countBoolean4) {
                        vo.setAprilCounts(count);
                    } else if (countBoolean5) {
                        vo.setMarchCounts(count);
                    } else if (countBoolean6) {
                        vo.setJuneCounts(count);
                    } else if (countBoolean7) {
                        vo.setJulyCounts(count);
                    } else if (countBoolean8) {
                        vo.setAugustCounts(count);
                    } else if (countBoolean9) {
                        vo.setSeptemberCounts(count);
                    } else if (countBoolean10) {
                        vo.setOctoberCounts(count);
                    } else if (countBoolean11) {
                        vo.setNovemberCounts(count);
                    } else if (countBoolean12) {
                        vo.setDecemberCounts(count);
                    }
                }
            }
        }
        return voList;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<GetCarServiceStaticsDriverVo> listDirver(GetCarServiceStaticsListDriverParam param) {
        List<GetCarServiceStaticsDriverVo> voList = tCarServiceStaticsMapper.listDirver(param);
        for (GetCarServiceStaticsDriverVo vo : voList)
        {
            if (null != vo && null != vo.getMonthDays() && !"".equals(vo.getMonthDays()))
            {
                String[] arr = vo.getMonthDays().split(",");
                for (String monthDay : arr)
                {
                    boolean dayBoolean1 = "01".equals(monthDay.substring(0, 2));
                    boolean dayBoolean2 = "02".equals(monthDay.substring(0, 2));
                    boolean dayBoolean3 = "03".equals(monthDay.substring(0, 2));
                    boolean dayBoolean4 = "04".equals(monthDay.substring(0, 2));
                    boolean dayBoolean5 = "05".equals(monthDay.substring(0, 2));
                    boolean dayBoolean6 = "06".equals(monthDay.substring(0, 2));
                    boolean dayBoolean7 = "07".equals(monthDay.substring(0, 2));
                    boolean dayBoolean8 = "08".equals(monthDay.substring(0, 2));
                    boolean dayBoolean9 = "09".equals(monthDay.substring(0, 2));
                    boolean dayBoolean10 = "10".equals(monthDay.substring(0, 2));
                    boolean dayBoolean11 = "11".equals(monthDay.substring(0, 2));
                    boolean dayBoolean12 = "12".equals(monthDay.substring(0, 2));
                    int day = Integer.parseInt(monthDay.substring(3, monthDay.length()));
                    if (dayBoolean1){
                        vo.setJanuaryDays(day);
                    } else if (dayBoolean2){
                        vo.setFebruaryDays(day);
                    } else if (dayBoolean3) {
                        vo.setMarchDays(day);
                    } else if (dayBoolean4) {
                        vo.setAprilDays(day);
                    }else if (dayBoolean5) {
                        vo.setMayDays(day);
                    }else if (dayBoolean6) {
                        vo.setJuneDays(day);
                    }else if (dayBoolean7) {
                        vo.setJulyDays(day);
                    }else if (dayBoolean8) {
                        vo.setAugustDays(day);
                    }else if (dayBoolean9) {
                        vo.setSeptemberDays(day);
                    }else if (dayBoolean10) {
                        vo.setOctoberDays(day);
                    }else if (dayBoolean11) {
                        vo.setNovemberDays(day);
                    }else if (dayBoolean12) {
                        vo.setDecemberDays(day);
                    }
                }
            }
            if (null != vo && null != vo.getMonthCounts() && !"".equals(vo.getMonthCounts()))
            {
                String[] arr = vo.getMonthCounts().split(",");
                for (String monthCounts : arr)
                {
                    boolean countBoolean1 = "01".equals(monthCounts.substring(0, 2));
                    boolean countBoolean2 = "02".equals(monthCounts.substring(0, 2));
                    boolean countBoolean3 = "03".equals(monthCounts.substring(0, 2));
                    boolean countBoolean4 = "04".equals(monthCounts.substring(0, 2));
                    boolean countBoolean5 = "05".equals(monthCounts.substring(0, 2));
                    boolean countBoolean6 = "06".equals(monthCounts.substring(0, 2));
                    boolean countBoolean7 = "07".equals(monthCounts.substring(0, 2));
                    boolean countBoolean8 = "08".equals(monthCounts.substring(0, 2));
                    boolean countBoolean9 = "09".equals(monthCounts.substring(0, 2));
                    boolean countBoolean10 = "10".equals(monthCounts.substring(0, 2));
                    boolean countBoolean11 = "11".equals(monthCounts.substring(0, 2));
                    boolean countBoolean12 = "12".equals(monthCounts.substring(0, 2));
                    int count = Integer.parseInt(monthCounts.substring(3, monthCounts.length()));
                    if (countBoolean1) {
                        vo.setJanuaryCounts(count);
                    } else if (countBoolean2) {
                        vo.setFebruaryCounts(count);
                    } else if (countBoolean3) {
                        vo.setMarchCounts(count);
                    } else if (countBoolean4) {
                        vo.setAprilCounts(count);
                    } else if (countBoolean5) {
                        vo.setMarchCounts(count);
                    } else if (countBoolean6) {
                        vo.setJuneCounts(count);
                    } else if (countBoolean7) {
                        vo.setJulyCounts(count);
                    } else if (countBoolean8) {
                        vo.setAugustCounts(count);
                    } else if (countBoolean9) {
                        vo.setSeptemberCounts(count);
                    } else if (countBoolean10) {
                        vo.setOctoberCounts(count);
                    } else if (countBoolean11) {
                        vo.setNovemberCounts(count);
                    } else if (countBoolean12) {
                        vo.setDecemberCounts(count);
                    }
                }
            }
        }
        return voList;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<GetCarServiceStaticsDriverDetailsVo> listDirverDetails(GetCarServiceStaticsListDriverDetailsParam param) {
        List<GetCarServiceStaticsDriverDetailsVo> voList = tCarServiceStaticsMapper.listDirverDetails(param);
        for (GetCarServiceStaticsDriverDetailsVo vo : voList)
        {
            if (null != vo && null != vo.getMonthDays() && !"".equals(vo.getMonthDays()))
            {
                String[] arr = vo.getMonthDays().split(",");
                for (String monthDay : arr)
                {
                    boolean dayBoolean1 = "01".equals(monthDay.substring(0, 2));
                    boolean dayBoolean2 = "02".equals(monthDay.substring(0, 2));
                    boolean dayBoolean3 = "03".equals(monthDay.substring(0, 2));
                    boolean dayBoolean4 = "04".equals(monthDay.substring(0, 2));
                    boolean dayBoolean5 = "05".equals(monthDay.substring(0, 2));
                    boolean dayBoolean6 = "06".equals(monthDay.substring(0, 2));
                    boolean dayBoolean7 = "07".equals(monthDay.substring(0, 2));
                    boolean dayBoolean8 = "08".equals(monthDay.substring(0, 2));
                    boolean dayBoolean9 = "09".equals(monthDay.substring(0, 2));
                    boolean dayBoolean10 = "10".equals(monthDay.substring(0, 2));
                    boolean dayBoolean11 = "11".equals(monthDay.substring(0, 2));
                    boolean dayBoolean12 = "12".equals(monthDay.substring(0, 2));
                    int day = Integer.parseInt(monthDay.substring(3, monthDay.length()));
                    if (dayBoolean1){
                        vo.setJanuaryDays(day);
                    } else if (dayBoolean2){
                        vo.setFebruaryDays(day);
                    } else if (dayBoolean3) {
                        vo.setMarchDays(day);
                    } else if (dayBoolean4) {
                        vo.setAprilDays(day);
                    }else if (dayBoolean5) {
                        vo.setMayDays(day);
                    }else if (dayBoolean6) {
                        vo.setJuneDays(day);
                    }else if (dayBoolean7) {
                        vo.setJulyDays(day);
                    }else if (dayBoolean8) {
                        vo.setAugustDays(day);
                    }else if (dayBoolean9) {
                        vo.setSeptemberDays(day);
                    }else if (dayBoolean10) {
                        vo.setOctoberDays(day);
                    }else if (dayBoolean11) {
                        vo.setNovemberDays(day);
                    }else if (dayBoolean12) {
                        vo.setDecemberDays(day);
                    }
                }
            }
            if (null != vo && null != vo.getMonthCounts() && !"".equals(vo.getMonthCounts()))
            {
                String[] arr = vo.getMonthCounts().split(",");
                for (String monthCounts : arr)
                {
                    boolean countBoolean1 = "01".equals(monthCounts.substring(0, 2));
                    boolean countBoolean2 = "02".equals(monthCounts.substring(0, 2));
                    boolean countBoolean3 = "03".equals(monthCounts.substring(0, 2));
                    boolean countBoolean4 = "04".equals(monthCounts.substring(0, 2));
                    boolean countBoolean5 = "05".equals(monthCounts.substring(0, 2));
                    boolean countBoolean6 = "06".equals(monthCounts.substring(0, 2));
                    boolean countBoolean7 = "07".equals(monthCounts.substring(0, 2));
                    boolean countBoolean8 = "08".equals(monthCounts.substring(0, 2));
                    boolean countBoolean9 = "09".equals(monthCounts.substring(0, 2));
                    boolean countBoolean10 = "10".equals(monthCounts.substring(0, 2));
                    boolean countBoolean11 = "11".equals(monthCounts.substring(0, 2));
                    boolean countBoolean12 = "12".equals(monthCounts.substring(0, 2));
                    int count = Integer.parseInt(monthCounts.substring(3, monthCounts.length()));
                    if (countBoolean1) {
                        vo.setJanuaryCounts(count);
                    } else if (countBoolean2) {
                        vo.setFebruaryCounts(count);
                    } else if (countBoolean3) {
                        vo.setMarchCounts(count);
                    } else if (countBoolean4) {
                        vo.setAprilCounts(count);
                    } else if (countBoolean5) {
                        vo.setMarchCounts(count);
                    } else if (countBoolean6) {
                        vo.setJuneCounts(count);
                    } else if (countBoolean7) {
                        vo.setJulyCounts(count);
                    } else if (countBoolean8) {
                        vo.setAugustCounts(count);
                    } else if (countBoolean9) {
                        vo.setSeptemberCounts(count);
                    } else if (countBoolean10) {
                        vo.setOctoberCounts(count);
                    } else if (countBoolean11) {
                        vo.setNovemberCounts(count);
                    } else if (countBoolean12) {
                        vo.setDecemberCounts(count);
                    }
                }
            }
        }
        return voList;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<GetCarServiceStaticsDriverDetailsDayVo> listDirverDetailsDay(GetCarServiceStaticsListDriverDetailsDayParam param) {
        List<GetCarServiceStaticsDriverDetailsDayVo> voList = tCarServiceStaticsMapper.listDirverDetailsDay(param);
        Iterator<GetCarServiceStaticsDriverDetailsDayVo> iterator = voList.iterator();
        List<GetCarServiceStaticsDriverDetailsDayTotalVo> totalVos = tCarServiceStaticsMapper.listDirverDetailsDayTotal(param);
        while(iterator.hasNext()){
            GetCarServiceStaticsDriverDetailsDayVo vo = iterator.next();
            for (GetCarServiceStaticsDriverDetailsDayTotalVo totalVo : totalVos) {
                if(vo.getCarNo().equals(totalVo.getCarNo())){
                    vo.setTotalDays(totalVo.getTotalDays());
                    vo.setTotalCounts(totalVo.getTotalCounts());
                }
            }
            List<GetCarServiceStaticsDriverDetailsDayCountsVo> list = new ArrayList<>();
            List<String> days = new ArrayList<>(
                    Arrays.asList("01","02","03","04","05","06","07","08","09","10",
                            "11","12","13","14","15","16","17","18","19","20",
                            "21","22","23","24","25","26","27","28","29","30",
                            "31"));
            Integer year = Integer.valueOf(param.getYear());
            if(param.getMonth().equals("02")){
                days.remove("30");
                if(!(year%400==0||(year%4==0 && year%100!=0))){
                    days.remove("29");
                }
            }
            if(!param.getMonth().equals("01")
                    && !param.getMonth().equals("03")
                    && !param.getMonth().equals("05")
                    && !param.getMonth().equals("07")
                    && !param.getMonth().equals("08")
                    && !param.getMonth().equals("10")
                    && !param.getMonth().equals("12")
            ){
                days.remove("31");
            }
            for (GetCarServiceStaticsDriverDetailsDayCountsVo day : vo.getCountsList()) {
                int dayDay = day.getDay();
                if(dayDay < 10){
                    days.remove("0"+day.getDay());
                }else {
                    days.remove(String.valueOf(day.getDay()));
                }
            }
            for (String d : days) {
                GetCarServiceStaticsDriverDetailsDayCountsVo dayCounts = new GetCarServiceStaticsDriverDetailsDayCountsVo();
                dayCounts.setDay(Integer.valueOf(d));
                dayCounts.setCounts(0);
                dayCounts.setCarNo(vo.getCarNo());
                list.add(dayCounts);
            }
            vo.getCountsList().addAll(list);
            vo.getCountsList().sort(Comparator.comparing(GetCarServiceStaticsDriverDetailsDayCountsVo::getDay));
        }
        return voList;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<GetCarServiceStaticsDriverExportVo> exportDriver(GetCarServiceStaticsListDriverParam param) {
        List<GetCarServiceStaticsDriverExportVo> voList = tCarServiceStaticsMapper.exportDriver(param);
        for (GetCarServiceStaticsDriverExportVo vo : voList) {
            if (null != vo.getMonthDays() && !"".equals(vo.getMonthDays()) && null != vo.getMonthCounts() && !"".equals(vo.getMonthCounts())) {
                String[] days = vo.getMonthDays().split(",");
                String[] count = vo.getMonthCounts().split(",");
                for (String monthDay : days) {
                    for (String monthCounts : count) {
                        boolean dayBoolean1 = "01".equals(monthDay.substring(0, 2));
                        boolean dayBoolean2 = "02".equals(monthDay.substring(0, 2));
                        boolean dayBoolean3 = "03".equals(monthDay.substring(0, 2));
                        boolean dayBoolean4 = "04".equals(monthDay.substring(0, 2));
                        boolean dayBoolean5 = "05".equals(monthDay.substring(0, 2));
                        boolean dayBoolean6 = "06".equals(monthDay.substring(0, 2));
                        boolean dayBoolean7 = "07".equals(monthDay.substring(0, 2));
                        boolean dayBoolean8 = "08".equals(monthDay.substring(0, 2));
                        boolean dayBoolean9 = "09".equals(monthDay.substring(0, 2));
                        boolean dayBoolean10 = "10".equals(monthDay.substring(0, 2));
                        boolean dayBoolean11 = "11".equals(monthDay.substring(0, 2));
                        boolean dayBoolean12 = "12".equals(monthDay.substring(0, 2));
                        boolean countBoolean1 = "01".equals(monthCounts.substring(0, 2));
                        boolean countBoolean2 = "02".equals(monthCounts.substring(0, 2));
                        boolean countBoolean3 = "03".equals(monthCounts.substring(0, 2));
                        boolean countBoolean4 = "04".equals(monthCounts.substring(0, 2));
                        boolean countBoolean5 = "05".equals(monthCounts.substring(0, 2));
                        boolean countBoolean6 = "06".equals(monthCounts.substring(0, 2));
                        boolean countBoolean7 = "07".equals(monthCounts.substring(0, 2));
                        boolean countBoolean8 = "08".equals(monthCounts.substring(0, 2));
                        boolean countBoolean9 = "09".equals(monthCounts.substring(0, 2));
                        boolean countBoolean10 = "10".equals(monthCounts.substring(0, 2));
                        boolean countBoolean11 = "11".equals(monthCounts.substring(0, 2));
                        boolean countBoolean12 = "12".equals(monthCounts.substring(0, 2));
                        String dc = Integer.parseInt(monthDay.substring(3, monthDay.length())) + "/" + Integer.parseInt(monthCounts.substring(3, monthCounts.length()));
                        if (dayBoolean1 && countBoolean1) {
                            vo.setJanuary(dc);
                        } else if (dayBoolean2 && countBoolean2) {
                            vo.setFebruary(dc);
                        } else if (dayBoolean3 && countBoolean3) {
                            vo.setMarch(dc);
                        } else if (dayBoolean4 && countBoolean4) {
                            vo.setApril(dc);
                        } else if (dayBoolean5 && countBoolean5) {
                            vo.setMay(dc);
                        } else if (dayBoolean6 && countBoolean6) {
                            vo.setJune(dc);
                        } else if (dayBoolean7 && countBoolean7) {
                            vo.setJuly(dc);
                        } else if (dayBoolean8 && countBoolean8) {
                            vo.setAugust(dc);
                        } else if (dayBoolean9 && countBoolean9) {
                            vo.setSeptember(dc);
                        } else if (dayBoolean10 && countBoolean10) {
                            vo.setOctober(dc);
                        } else if (dayBoolean11 && countBoolean11) {
                            vo.setNovember(dc);
                        } else if (dayBoolean12 && countBoolean12) {
                            vo.setDecember(dc);
                        }
                    }
                }
            }
            String d = "0/0";
            if(StringUtils.isEmpty(vo.getJanuary())){
                vo.setJanuary(d);
            }
            if (StringUtils.isEmpty(vo.getFebruary())) {
                vo.setFebruary(d);
            }
            if (StringUtils.isEmpty(vo.getMarch())) {
                vo.setMarch(d);
            }
            if (StringUtils.isEmpty(vo.getApril())) {
                vo.setApril(d);
            }
            if (StringUtils.isEmpty(vo.getMay())) {
                vo.setMay(d);
            }
            if (StringUtils.isEmpty(vo.getJune())) {
                vo.setJune(d);
            }
            if (StringUtils.isEmpty(vo.getJuly())) {
                vo.setJuly(d);
            }
            if (StringUtils.isEmpty(vo.getAugust())) {
                vo.setAugust(d);
            }
            if (StringUtils.isEmpty(vo.getSeptember())) {
                vo.setSeptember(d);
            }
            if (StringUtils.isEmpty(vo.getOctober())) {
                vo.setOctober(d);
            }
            if (StringUtils.isEmpty(vo.getNovember())) {
                vo.setNovember(d);
            }
            if (StringUtils.isEmpty(vo.getDecember())) {
                vo.setDecember(d);
            }
        }
        return voList;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<GetCarServiceStaticsDetailsDayVo> listDetailsDay(GetCarServiceStaticsListDetailsDayParam param) {
        List<GetCarServiceStaticsDetailsDayVo> voList = tCarServiceStaticsMapper.listDetailsDay(param);
        Iterator<GetCarServiceStaticsDetailsDayVo> iterator = voList.iterator();
        List<GetCarServiceStaticsDetailsDayTotalVo> totalVos = tCarServiceStaticsMapper.listDetailsDayTotal(param);
        while(iterator.hasNext()){
            GetCarServiceStaticsDetailsDayVo vo = iterator.next();
            for (GetCarServiceStaticsDetailsDayTotalVo totalVo : totalVos) {
                if(vo.getEmployeeId().equals(totalVo.getEmployeeId())){
                    vo.setTotalDays(totalVo.getTotalDays());
                    vo.setTotalCounts(totalVo.getTotalCounts());
                }
            }
            List<GetCarServiceStaticsDetailsDayCountsVo> list = new ArrayList<>();
            List<String> days = new ArrayList<>(
                    Arrays.asList("01","02","03","04","05","06","07","08","09","10",
                            "11","12","13","14","15","16","17","18","19","20",
                            "21","22","23","24","25","26","27","28","29","30",
                            "31"));
            Integer year = Integer.valueOf(param.getYear());
            if(param.getMonth().equals("02")){
                days.remove("30");
                if(!(year%400==0||(year%4==0 && year%100!=0))){
                    days.remove("29");
                }
            }
            if(!param.getMonth().equals("01")
                    && !param.getMonth().equals("03")
                    && !param.getMonth().equals("05")
                    && !param.getMonth().equals("07")
                    && !param.getMonth().equals("08")
                    && !param.getMonth().equals("10")
                    && !param.getMonth().equals("12")
            ){
                days.remove("31");
            }
            for (GetCarServiceStaticsDetailsDayCountsVo day : vo.getCountsList()) {
                int dayDay = day.getDay();
                if(dayDay < 10){
                    days.remove("0"+day.getDay());
                }else {
                    days.remove(String.valueOf(day.getDay()));
                }
            }
            for (String d : days) {
                GetCarServiceStaticsDetailsDayCountsVo dayCounts = new GetCarServiceStaticsDetailsDayCountsVo();
                dayCounts.setDay(Integer.valueOf(d));
                dayCounts.setCounts(0);
                dayCounts.setEmployeeName(vo.getEmployeeName());
                list.add(dayCounts);
            }
            vo.getCountsList().addAll(list);
            vo.getCountsList().sort(Comparator.comparing(GetCarServiceStaticsDetailsDayCountsVo::getDay));
        }
        return voList;
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveCarServiceStaticsList(List<TCarServiceStatics> list) {
        tCarServiceStaticsMapper.saveCarServiceStaticsList(list);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveCarServiceStatics(TCarServiceStatics statics) {
        tCarServiceStaticsMapper.addCarServiceStatics(statics);
    }


}
